package com.example.socketdemo3;

import java.util.concurrent.ArrayBlockingQueue;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;

/**
 * @author zhanghui
 * @date 2021/12/6 9:59
 */
public class HandlerSocketThreadPool {
    private ExecutorService executor;

    public HandlerSocketThreadPool(int maxPoolSize, int queueSize) {
        this.executor = new ThreadPoolExecutor(3, maxPoolSize, 120L, TimeUnit.SECONDS, new ArrayBlockingQueue<>(queueSize));
        System.out.println("线程池创建成功");
    }

    public void execute(Runnable task) {
        this.executor.execute(task);
    }
}
